//
//  Person.m
//  OC06_作业
//
//  Created by dllo on 15/12/8.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "Person.h"

@implementation Person

- (instancetype)initWithName:(NSString *)name
                         age:(NSInteger)age
                         sex:(NSString *)sex {
    self = [super init];
    if (self) {
        self.name = name;
        self.age = age;
        self.sex = sex;
    }
    return self;
}

- (Person *)compareWithAge:(Person *)per {
    if (self.age > per.age) {
        
        return self;
    } else {
        return per;
    }
}




- (NSComparisonResult)compareWithNameUp:(Person *)anotherPerson {
    return [self.name compare:anotherPerson.name];
}

- (NSComparisonResult)compareWithAgeUp:(Person *)anotherPerson {
    if (self.age > anotherPerson.age) {
        return NSOrderedDescending;
    } else if (self.age < anotherPerson.age) {
        return NSOrderedAscending;
    } else {
        return NSOrderedSame;
    }
}




@end
